package o;

import android.os.Handler;
import android.os.Looper;
import android.view.View;
import android.widget.TextView;
import com.huawei.appgallery.forum.message.api.IMessageHomeProtocol;
import com.huawei.fastengine.fastview.download.utils.PackageUtils;
import java.lang.ref.WeakReference;
import java.util.HashMap;
import o.cab.c;
import o.cab.e;
import o.cab.i;

public class cak extends cae {
    private TextView ʻ;
    private Handler ʽ;
    private View ˋ;
    private String ॱ;
    private fkg ॱॱ;

    static class d implements Runnable {
        private final String ˎ;
        private WeakReference<cak> ˏ;

        private d(cak o_cak, String str) {
            this.ˏ = new WeakReference(o_cak);
            this.ˎ = str;
        }

        public void run() {
            cak o_cak = (cak) this.ˏ.get();
            if (o_cak != null) {
                o_cak.ॱ = this.ˎ;
                o_cak.ʼ();
            }
        }
    }

    public int ˏ() {
        return i.ʼॱ;
    }

    public void onClick(View view) {
        fjb ˎ = fho.ˏ().ˋ("Message").ˎ("message_home_activity");
        IMessageHomeProtocol iMessageHomeProtocol = (IMessageHomeProtocol) ˎ.ˊ();
        String packageName = view.getContext().getPackageName();
        if (PackageUtils.HWGAMEBOX_PACKAGE_NAME.equals(packageName)) {
            iMessageHomeProtocol.setSourceType(0);
            iMessageHomeProtocol.setDomainId(bqv.ˊ.ˎ());
        } else if ("com.huawei.appmarket".equals(packageName)) {
            iMessageHomeProtocol.setSourceType(1);
            iMessageHomeProtocol.setDomainId(bqv.ˎ.ˎ());
        }
        fiu.ˊ().ˏ(view.getContext(), ˎ);
    }

    public int ˋ() {
        return e.ॱʻ;
    }

    public int ˊ() {
        return e.ॱͺ;
    }

    public void ˊ(View view) {
        super.ˊ(view);
        this.ˋ = view;
        this.ʻ = (TextView) view.findViewById(e.ˏˏ);
        this.ʽ = new Handler(Looper.getMainLooper());
        ʻ();
    }

    public void ʼ() {
        if (this.ˋ != null) {
            if (cgy.ˎ(this.ॱ)) {
                this.ʻ.setVisibility(8);
                return;
            }
            this.ʻ.setVisibility(0);
            this.ʻ.setHeight(this.ˋ.getContext().getResources().getDimensionPixelSize(c.ˊॱ));
            if (this.ॱ.length() == 1) {
                this.ʻ.setText(String.valueOf(this.ॱ));
                this.ʻ.setPadding(0, 0, 0, 0);
                this.ʻ.setBackgroundResource(o.cab.d.ʼ);
                return;
            }
            int dimensionPixelSize = this.ˋ.getContext().getResources().getDimensionPixelSize(c.ॱˋ);
            this.ʻ.setPadding(dimensionPixelSize, 0, dimensionPixelSize, 0);
            this.ʻ.setBackgroundResource(o.cab.d.ᐝ);
            this.ʻ.setText(this.ॱ);
        }
    }

    public int ॱ() {
        return o.cab.d.ˊ;
    }

    public void ˏ(int i, float f) {
        if (this.ˊ != null) {
            this.ˊ.setBackground(epo.ॱ(this.ˎ, i));
            if (this.ʻ != null) {
                this.ʻ.setAlpha(f);
            }
        }
    }

    private void ʻ() {
        ((bvn) fho.ˏ().ˋ("Message").ॱ(bvn.class)).ˊ("MsgRemindMenu" + System.currentTimeMillis()).ˋ(fjt.ˋ(), new fke<HashMap<String, String>>(this) {
            final /* synthetic */ cak ˎ;

            {
                this.ˎ = r1;
            }

            public /* synthetic */ void ॱ(Object obj) {
                ˋ((HashMap) obj);
            }

            public void ˎ(fkg o_fkg) {
                this.ˎ.ॱॱ = o_fkg;
            }

            public void ˋ(HashMap<String, String> hashMap) {
                if (hashMap == null) {
                    bqx.ˏ("MsgRemindMenu", "unReadMsgCountMap is null");
                    return;
                }
                String str = (String) hashMap.get(bqv.ˎ.ˎ());
                bqx.ˊ("MsgRemindMenu", "getTotalUnReadMsg :" + str);
                this.ˎ.ʽ.post(new d(str));
            }

            public void ˊ(Exception exception) {
                bqx.ˋ("MsgRemindMenu", "getTotalUnReadMsg onFailure");
            }

            public void ॱ() {
                bqx.ˋ("MsgRemindMenu", "getTotalUnReadMsg onComplete");
            }
        });
    }

    public void ˎ() {
        super.ˎ();
        if (this.ॱॱ != null) {
            this.ॱॱ.ˋ();
        }
    }
}
